#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

//孩子们的游戏(圆圈中最后剩下的数)，动态规划，f(n) = [f(n-1) + m] % n
int LastRemaining_Solution(int n, int m)
{
    if (n == 0)
    {
        return -1;
    }
    if (n == 1)
    {
        return 0;
    }
    return (LastRemaining_Solution(n - 1, m) + m) % n;
}

void test()
{
}

int main()
{
    test();
    return 0;
}